using System;
using System.ComponentModel;
using System.Data;
using System.Windows.Forms;
using C1.Win.C1Input;
using C1.Win.C1TrueDBGrid;
using PCSComProcurement.Purchase.BO;
using PCSComUtils.Common;
using PCSComUtils.PCSExc;
using PCSUtils.Log;
using PCSUtils.Utils;
using CancelEventArgs = C1.Win.C1TrueDBGrid.CancelEventArgs;

namespace PCSProcurement.Purchase
{
	/// <summary>
	/// Summary description for PODeliveryByHour.
	/// </summary>
	public class PODeliveryByHour : Form
	{
		private Button btnSave;
		private Button btnClose;
		private Panel pnlRoleProtection;
		private Button btnHelp;
		private C1TrueDBGrid dgrdData;
		private Label lblType;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private Container components = null;
		const string THIS = "PCSProcurement.Purchase.PODeliveryByHour";		
		DataSet dstVendor = new DataSet();
		private ComboBox cboType;
		private Label lblDaily;
		private Label lblWeekly;
		private Label lblMonthly;
		DataSet dstData = new DataSet();
		DataTable dtbData = new DataTable();
		private DataTable dtbGridLayOut;
		private const string TIME = "Time";
		private Panel pnlLeft;
		private Splitter splitter1;
		private Panel pnlRight;
		private Label lblItems;
		private Label label1;
		private C1TrueDBGrid dgrdVendor;
		private const string TIME_FORMAT = "HH:mm";
		const int MIN_DATE = 1;
		const int MAX_DATE = 31;

		public PODeliveryByHour()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PODeliveryByHour));
			this.btnSave = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			this.pnlRoleProtection = new System.Windows.Forms.Panel();
			this.pnlRight = new System.Windows.Forms.Panel();
			this.lblItems = new System.Windows.Forms.Label();
			this.dgrdData = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.pnlLeft = new System.Windows.Forms.Panel();
			this.dgrdVendor = new C1.Win.C1TrueDBGrid.C1TrueDBGrid();
			this.label1 = new System.Windows.Forms.Label();
			this.btnHelp = new System.Windows.Forms.Button();
			this.lblType = new System.Windows.Forms.Label();
			this.cboType = new System.Windows.Forms.ComboBox();
			this.lblDaily = new System.Windows.Forms.Label();
			this.lblWeekly = new System.Windows.Forms.Label();
			this.lblMonthly = new System.Windows.Forms.Label();
			this.pnlRoleProtection.SuspendLayout();
			this.pnlRight.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).BeginInit();
			this.pnlLeft.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dgrdVendor)).BeginInit();
			this.SuspendLayout();
			// 
			// btnSave
			// 
			this.btnSave.AccessibleDescription = resources.GetString("btnSave.AccessibleDescription");
			this.btnSave.AccessibleName = resources.GetString("btnSave.AccessibleName");
			this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnSave.Anchor")));
			this.btnSave.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSave.BackgroundImage")));
			this.btnSave.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnSave.Dock")));
			this.btnSave.Enabled = ((bool)(resources.GetObject("btnSave.Enabled")));
			this.btnSave.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnSave.FlatStyle")));
			this.btnSave.Font = ((System.Drawing.Font)(resources.GetObject("btnSave.Font")));
			this.btnSave.Image = ((System.Drawing.Image)(resources.GetObject("btnSave.Image")));
			this.btnSave.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.ImageAlign")));
			this.btnSave.ImageIndex = ((int)(resources.GetObject("btnSave.ImageIndex")));
			this.btnSave.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnSave.ImeMode")));
			this.btnSave.Location = ((System.Drawing.Point)(resources.GetObject("btnSave.Location")));
			this.btnSave.Name = "btnSave";
			this.btnSave.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnSave.RightToLeft")));
			this.btnSave.Size = ((System.Drawing.Size)(resources.GetObject("btnSave.Size")));
			this.btnSave.TabIndex = ((int)(resources.GetObject("btnSave.TabIndex")));
			this.btnSave.Text = resources.GetString("btnSave.Text");
			this.btnSave.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnSave.TextAlign")));
			this.btnSave.Visible = ((bool)(resources.GetObject("btnSave.Visible")));
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			// 
			// btnClose
			// 
			this.btnClose.AccessibleDescription = resources.GetString("btnClose.AccessibleDescription");
			this.btnClose.AccessibleName = resources.GetString("btnClose.AccessibleName");
			this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnClose.Anchor")));
			this.btnClose.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnClose.BackgroundImage")));
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnClose.Dock")));
			this.btnClose.Enabled = ((bool)(resources.GetObject("btnClose.Enabled")));
			this.btnClose.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnClose.FlatStyle")));
			this.btnClose.Font = ((System.Drawing.Font)(resources.GetObject("btnClose.Font")));
			this.btnClose.Image = ((System.Drawing.Image)(resources.GetObject("btnClose.Image")));
			this.btnClose.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.ImageAlign")));
			this.btnClose.ImageIndex = ((int)(resources.GetObject("btnClose.ImageIndex")));
			this.btnClose.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnClose.ImeMode")));
			this.btnClose.Location = ((System.Drawing.Point)(resources.GetObject("btnClose.Location")));
			this.btnClose.Name = "btnClose";
			this.btnClose.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnClose.RightToLeft")));
			this.btnClose.Size = ((System.Drawing.Size)(resources.GetObject("btnClose.Size")));
			this.btnClose.TabIndex = ((int)(resources.GetObject("btnClose.TabIndex")));
			this.btnClose.Text = resources.GetString("btnClose.Text");
			this.btnClose.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnClose.TextAlign")));
			this.btnClose.Visible = ((bool)(resources.GetObject("btnClose.Visible")));
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// pnlRoleProtection
			// 
			this.pnlRoleProtection.AccessibleDescription = resources.GetString("pnlRoleProtection.AccessibleDescription");
			this.pnlRoleProtection.AccessibleName = resources.GetString("pnlRoleProtection.AccessibleName");
			this.pnlRoleProtection.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("pnlRoleProtection.Anchor")));
			this.pnlRoleProtection.AutoScroll = ((bool)(resources.GetObject("pnlRoleProtection.AutoScroll")));
			this.pnlRoleProtection.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("pnlRoleProtection.AutoScrollMargin")));
			this.pnlRoleProtection.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("pnlRoleProtection.AutoScrollMinSize")));
			this.pnlRoleProtection.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pnlRoleProtection.BackgroundImage")));
			this.pnlRoleProtection.Controls.Add(this.pnlRight);
			this.pnlRoleProtection.Controls.Add(this.splitter1);
			this.pnlRoleProtection.Controls.Add(this.pnlLeft);
			this.pnlRoleProtection.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("pnlRoleProtection.Dock")));
			this.pnlRoleProtection.Enabled = ((bool)(resources.GetObject("pnlRoleProtection.Enabled")));
			this.pnlRoleProtection.Font = ((System.Drawing.Font)(resources.GetObject("pnlRoleProtection.Font")));
			this.pnlRoleProtection.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("pnlRoleProtection.ImeMode")));
			this.pnlRoleProtection.Location = ((System.Drawing.Point)(resources.GetObject("pnlRoleProtection.Location")));
			this.pnlRoleProtection.Name = "pnlRoleProtection";
			this.pnlRoleProtection.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("pnlRoleProtection.RightToLeft")));
			this.pnlRoleProtection.Size = ((System.Drawing.Size)(resources.GetObject("pnlRoleProtection.Size")));
			this.pnlRoleProtection.TabIndex = ((int)(resources.GetObject("pnlRoleProtection.TabIndex")));
			this.pnlRoleProtection.Text = resources.GetString("pnlRoleProtection.Text");
			this.pnlRoleProtection.Visible = ((bool)(resources.GetObject("pnlRoleProtection.Visible")));
			// 
			// pnlRight
			// 
			this.pnlRight.AccessibleDescription = resources.GetString("pnlRight.AccessibleDescription");
			this.pnlRight.AccessibleName = resources.GetString("pnlRight.AccessibleName");
			this.pnlRight.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("pnlRight.Anchor")));
			this.pnlRight.AutoScroll = ((bool)(resources.GetObject("pnlRight.AutoScroll")));
			this.pnlRight.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("pnlRight.AutoScrollMargin")));
			this.pnlRight.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("pnlRight.AutoScrollMinSize")));
			this.pnlRight.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pnlRight.BackgroundImage")));
			this.pnlRight.Controls.Add(this.lblItems);
			this.pnlRight.Controls.Add(this.dgrdData);
			this.pnlRight.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("pnlRight.Dock")));
			this.pnlRight.Enabled = ((bool)(resources.GetObject("pnlRight.Enabled")));
			this.pnlRight.Font = ((System.Drawing.Font)(resources.GetObject("pnlRight.Font")));
			this.pnlRight.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("pnlRight.ImeMode")));
			this.pnlRight.Location = ((System.Drawing.Point)(resources.GetObject("pnlRight.Location")));
			this.pnlRight.Name = "pnlRight";
			this.pnlRight.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("pnlRight.RightToLeft")));
			this.pnlRight.Size = ((System.Drawing.Size)(resources.GetObject("pnlRight.Size")));
			this.pnlRight.TabIndex = ((int)(resources.GetObject("pnlRight.TabIndex")));
			this.pnlRight.Text = resources.GetString("pnlRight.Text");
			this.pnlRight.Visible = ((bool)(resources.GetObject("pnlRight.Visible")));
			// 
			// lblItems
			// 
			this.lblItems.AccessibleDescription = resources.GetString("lblItems.AccessibleDescription");
			this.lblItems.AccessibleName = resources.GetString("lblItems.AccessibleName");
			this.lblItems.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblItems.Anchor")));
			this.lblItems.AutoSize = ((bool)(resources.GetObject("lblItems.AutoSize")));
			this.lblItems.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblItems.Dock")));
			this.lblItems.Enabled = ((bool)(resources.GetObject("lblItems.Enabled")));
			this.lblItems.Font = ((System.Drawing.Font)(resources.GetObject("lblItems.Font")));
			this.lblItems.Image = ((System.Drawing.Image)(resources.GetObject("lblItems.Image")));
			this.lblItems.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblItems.ImageAlign")));
			this.lblItems.ImageIndex = ((int)(resources.GetObject("lblItems.ImageIndex")));
			this.lblItems.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblItems.ImeMode")));
			this.lblItems.Location = ((System.Drawing.Point)(resources.GetObject("lblItems.Location")));
			this.lblItems.Name = "lblItems";
			this.lblItems.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblItems.RightToLeft")));
			this.lblItems.Size = ((System.Drawing.Size)(resources.GetObject("lblItems.Size")));
			this.lblItems.TabIndex = ((int)(resources.GetObject("lblItems.TabIndex")));
			this.lblItems.Text = resources.GetString("lblItems.Text");
			this.lblItems.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblItems.TextAlign")));
			this.lblItems.Visible = ((bool)(resources.GetObject("lblItems.Visible")));
			// 
			// dgrdData
			// 
			this.dgrdData.AccessibleDescription = resources.GetString("dgrdData.AccessibleDescription");
			this.dgrdData.AccessibleName = resources.GetString("dgrdData.AccessibleName");
			this.dgrdData.AllowAddNew = ((bool)(resources.GetObject("dgrdData.AllowAddNew")));
			this.dgrdData.AllowArrows = ((bool)(resources.GetObject("dgrdData.AllowArrows")));
			this.dgrdData.AllowColMove = ((bool)(resources.GetObject("dgrdData.AllowColMove")));
			this.dgrdData.AllowColSelect = ((bool)(resources.GetObject("dgrdData.AllowColSelect")));
			this.dgrdData.AllowDelete = ((bool)(resources.GetObject("dgrdData.AllowDelete")));
			this.dgrdData.AllowDrag = ((bool)(resources.GetObject("dgrdData.AllowDrag")));
			this.dgrdData.AllowFilter = ((bool)(resources.GetObject("dgrdData.AllowFilter")));
			this.dgrdData.AllowHorizontalSplit = ((bool)(resources.GetObject("dgrdData.AllowHorizontalSplit")));
			this.dgrdData.AllowRowSelect = ((bool)(resources.GetObject("dgrdData.AllowRowSelect")));
			this.dgrdData.AllowSort = ((bool)(resources.GetObject("dgrdData.AllowSort")));
			this.dgrdData.AllowUpdate = ((bool)(resources.GetObject("dgrdData.AllowUpdate")));
			this.dgrdData.AllowUpdateOnBlur = ((bool)(resources.GetObject("dgrdData.AllowUpdateOnBlur")));
			this.dgrdData.AllowVerticalSplit = ((bool)(resources.GetObject("dgrdData.AllowVerticalSplit")));
			this.dgrdData.AlternatingRows = ((bool)(resources.GetObject("dgrdData.AlternatingRows")));
			this.dgrdData.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dgrdData.Anchor")));
			this.dgrdData.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dgrdData.BackgroundImage")));
			this.dgrdData.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("dgrdData.BorderStyle")));
			this.dgrdData.Caption = resources.GetString("dgrdData.Caption");
			this.dgrdData.CaptionHeight = ((int)(resources.GetObject("dgrdData.CaptionHeight")));
			this.dgrdData.CellTipsDelay = ((int)(resources.GetObject("dgrdData.CellTipsDelay")));
			this.dgrdData.CellTipsWidth = ((int)(resources.GetObject("dgrdData.CellTipsWidth")));
			this.dgrdData.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("dgrdData.ChildGrid")));
			this.dgrdData.CollapseColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.CollapseColor")));
			this.dgrdData.ColumnFooters = ((bool)(resources.GetObject("dgrdData.ColumnFooters")));
			this.dgrdData.ColumnHeaders = ((bool)(resources.GetObject("dgrdData.ColumnHeaders")));
			this.dgrdData.DefColWidth = ((int)(resources.GetObject("dgrdData.DefColWidth")));
			this.dgrdData.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dgrdData.Dock")));
			this.dgrdData.EditDropDown = ((bool)(resources.GetObject("dgrdData.EditDropDown")));
			this.dgrdData.EmptyRows = ((bool)(resources.GetObject("dgrdData.EmptyRows")));
			this.dgrdData.Enabled = ((bool)(resources.GetObject("dgrdData.Enabled")));
			this.dgrdData.ExpandColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.ExpandColor")));
			this.dgrdData.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("dgrdData.ExposeCellMode")));
			this.dgrdData.ExtendRightColumn = ((bool)(resources.GetObject("dgrdData.ExtendRightColumn")));
			this.dgrdData.FetchRowStyles = ((bool)(resources.GetObject("dgrdData.FetchRowStyles")));
			this.dgrdData.FilterBar = ((bool)(resources.GetObject("dgrdData.FilterBar")));
			this.dgrdData.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("dgrdData.FlatStyle")));
			this.dgrdData.Font = ((System.Drawing.Font)(resources.GetObject("dgrdData.Font")));
			this.dgrdData.GroupByAreaVisible = ((bool)(resources.GetObject("dgrdData.GroupByAreaVisible")));
			this.dgrdData.GroupByCaption = resources.GetString("dgrdData.GroupByCaption");
			this.dgrdData.Images.Add(((System.Drawing.Image)(resources.GetObject("resource"))));
			this.dgrdData.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dgrdData.ImeMode")));
			this.dgrdData.LinesPerRow = ((int)(resources.GetObject("dgrdData.LinesPerRow")));
			this.dgrdData.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.Location")));
			this.dgrdData.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.dgrdData.Name = "dgrdData";
			this.dgrdData.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureAddnewRow")));
			this.dgrdData.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureCurrentRow")));
			this.dgrdData.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFilterBar")));
			this.dgrdData.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureFooterRow")));
			this.dgrdData.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureHeaderRow")));
			this.dgrdData.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureModifiedRow")));
			this.dgrdData.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("dgrdData.PictureStandardRow")));
			this.dgrdData.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("dgrdData.PreviewInfo.AllowSizing")));
			this.dgrdData.PreviewInfo.Caption = resources.GetString("dgrdData.PreviewInfo.Caption");
			this.dgrdData.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("dgrdData.PreviewInfo.Location")));
			this.dgrdData.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.PreviewInfo.Size")));
			this.dgrdData.PreviewInfo.ToolBars = ((bool)(resources.GetObject("dgrdData.PreviewInfo.ToolBars")));
			this.dgrdData.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("dgrdData.PreviewInfo.UIStrings.Content")));
			this.dgrdData.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("dgrdData.PreviewInfo.ZoomFactor")));
			this.dgrdData.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.MaxRowHeight")));
			this.dgrdData.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageFooter")));
			this.dgrdData.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.OwnerDrawPageHeader")));
			this.dgrdData.PrintInfo.PageFooter = resources.GetString("dgrdData.PrintInfo.PageFooter");
			this.dgrdData.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageFooterHeight")));
			this.dgrdData.PrintInfo.PageHeader = resources.GetString("dgrdData.PrintInfo.PageHeader");
			this.dgrdData.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("dgrdData.PrintInfo.PageHeaderHeight")));
			this.dgrdData.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("dgrdData.PrintInfo.PrintHorizontalSplits")));
			this.dgrdData.PrintInfo.ProgressCaption = resources.GetString("dgrdData.PrintInfo.ProgressCaption");
			this.dgrdData.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnFooters")));
			this.dgrdData.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatColumnHeaders")));
			this.dgrdData.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatGridHeader")));
			this.dgrdData.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("dgrdData.PrintInfo.RepeatSplitHeaders")));
			this.dgrdData.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowOptionsDialog")));
			this.dgrdData.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowProgressForm")));
			this.dgrdData.PrintInfo.ShowSelection = ((bool)(resources.GetObject("dgrdData.PrintInfo.ShowSelection")));
			this.dgrdData.PrintInfo.UseGridColors = ((bool)(resources.GetObject("dgrdData.PrintInfo.UseGridColors")));
			this.dgrdData.RecordSelectors = ((bool)(resources.GetObject("dgrdData.RecordSelectors")));
			this.dgrdData.RecordSelectorWidth = ((int)(resources.GetObject("dgrdData.RecordSelectorWidth")));
			this.dgrdData.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dgrdData.RightToLeft")));
			this.dgrdData.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color")));
			this.dgrdData.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style")));
			this.dgrdData.RowHeight = ((int)(resources.GetObject("dgrdData.RowHeight")));
			this.dgrdData.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("dgrdData.RowSubDividerColor")));
			this.dgrdData.ScrollTips = ((bool)(resources.GetObject("dgrdData.ScrollTips")));
			this.dgrdData.ScrollTrack = ((bool)(resources.GetObject("dgrdData.ScrollTrack")));
			this.dgrdData.Size = ((System.Drawing.Size)(resources.GetObject("dgrdData.Size")));
			this.dgrdData.SpringMode = ((bool)(resources.GetObject("dgrdData.SpringMode")));
			this.dgrdData.TabAcrossSplits = ((bool)(resources.GetObject("dgrdData.TabAcrossSplits")));
			this.dgrdData.TabIndex = ((int)(resources.GetObject("dgrdData.TabIndex")));
			this.dgrdData.Text = resources.GetString("dgrdData.Text");
			this.dgrdData.ViewCaptionWidth = ((int)(resources.GetObject("dgrdData.ViewCaptionWidth")));
			this.dgrdData.ViewColumnWidth = ((int)(resources.GetObject("dgrdData.ViewColumnWidth")));
			this.dgrdData.Visible = ((bool)(resources.GetObject("dgrdData.Visible")));
			this.dgrdData.WrapCellPointer = ((bool)(resources.GetObject("dgrdData.WrapCellPointer")));
			this.dgrdData.ButtonClick += new C1.Win.C1TrueDBGrid.ColEventHandler(this.dgrdData_ButtonClick);
			this.dgrdData.AfterColUpdate += new C1.Win.C1TrueDBGrid.ColEventHandler(this.dgrdData_AfterColUpdate);
			this.dgrdData.BeforeColUpdate += new C1.Win.C1TrueDBGrid.BeforeColUpdateEventHandler(this.dgrdData_BeforeColUpdate);
			this.dgrdData.BeforeDelete += new C1.Win.C1TrueDBGrid.CancelEventHandler(this.dgrdData_BeforeDelete);
			this.dgrdData.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dgrdData_KeyDown);
			this.dgrdData.Error += new C1.Win.C1TrueDBGrid.ErrorEventHandler(this.dgrdData_Error);
			this.dgrdData.PropBag = resources.GetString("dgrdData.PropBag");
			// 
			// splitter1
			// 
			this.splitter1.AccessibleDescription = resources.GetString("splitter1.AccessibleDescription");
			this.splitter1.AccessibleName = resources.GetString("splitter1.AccessibleName");
			this.splitter1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("splitter1.Anchor")));
			this.splitter1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("splitter1.BackgroundImage")));
			this.splitter1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("splitter1.Dock")));
			this.splitter1.Enabled = ((bool)(resources.GetObject("splitter1.Enabled")));
			this.splitter1.Font = ((System.Drawing.Font)(resources.GetObject("splitter1.Font")));
			this.splitter1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("splitter1.ImeMode")));
			this.splitter1.Location = ((System.Drawing.Point)(resources.GetObject("splitter1.Location")));
			this.splitter1.MinExtra = ((int)(resources.GetObject("splitter1.MinExtra")));
			this.splitter1.MinSize = ((int)(resources.GetObject("splitter1.MinSize")));
			this.splitter1.Name = "splitter1";
			this.splitter1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("splitter1.RightToLeft")));
			this.splitter1.Size = ((System.Drawing.Size)(resources.GetObject("splitter1.Size")));
			this.splitter1.TabIndex = ((int)(resources.GetObject("splitter1.TabIndex")));
			this.splitter1.TabStop = false;
			this.splitter1.Visible = ((bool)(resources.GetObject("splitter1.Visible")));
			// 
			// pnlLeft
			// 
			this.pnlLeft.AccessibleDescription = resources.GetString("pnlLeft.AccessibleDescription");
			this.pnlLeft.AccessibleName = resources.GetString("pnlLeft.AccessibleName");
			this.pnlLeft.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("pnlLeft.Anchor")));
			this.pnlLeft.AutoScroll = ((bool)(resources.GetObject("pnlLeft.AutoScroll")));
			this.pnlLeft.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("pnlLeft.AutoScrollMargin")));
			this.pnlLeft.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("pnlLeft.AutoScrollMinSize")));
			this.pnlLeft.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pnlLeft.BackgroundImage")));
			this.pnlLeft.Controls.Add(this.dgrdVendor);
			this.pnlLeft.Controls.Add(this.label1);
			this.pnlLeft.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("pnlLeft.Dock")));
			this.pnlLeft.Enabled = ((bool)(resources.GetObject("pnlLeft.Enabled")));
			this.pnlLeft.Font = ((System.Drawing.Font)(resources.GetObject("pnlLeft.Font")));
			this.pnlLeft.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("pnlLeft.ImeMode")));
			this.pnlLeft.Location = ((System.Drawing.Point)(resources.GetObject("pnlLeft.Location")));
			this.pnlLeft.Name = "pnlLeft";
			this.pnlLeft.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("pnlLeft.RightToLeft")));
			this.pnlLeft.Size = ((System.Drawing.Size)(resources.GetObject("pnlLeft.Size")));
			this.pnlLeft.TabIndex = ((int)(resources.GetObject("pnlLeft.TabIndex")));
			this.pnlLeft.Text = resources.GetString("pnlLeft.Text");
			this.pnlLeft.Visible = ((bool)(resources.GetObject("pnlLeft.Visible")));
			// 
			// dgrdVendor
			// 
			this.dgrdVendor.AccessibleDescription = resources.GetString("dgrdVendor.AccessibleDescription");
			this.dgrdVendor.AccessibleName = resources.GetString("dgrdVendor.AccessibleName");
			this.dgrdVendor.AllowAddNew = ((bool)(resources.GetObject("dgrdVendor.AllowAddNew")));
			this.dgrdVendor.AllowArrows = ((bool)(resources.GetObject("dgrdVendor.AllowArrows")));
			this.dgrdVendor.AllowColMove = ((bool)(resources.GetObject("dgrdVendor.AllowColMove")));
			this.dgrdVendor.AllowColSelect = ((bool)(resources.GetObject("dgrdVendor.AllowColSelect")));
			this.dgrdVendor.AllowDelete = ((bool)(resources.GetObject("dgrdVendor.AllowDelete")));
			this.dgrdVendor.AllowDrag = ((bool)(resources.GetObject("dgrdVendor.AllowDrag")));
			this.dgrdVendor.AllowFilter = ((bool)(resources.GetObject("dgrdVendor.AllowFilter")));
			this.dgrdVendor.AllowHorizontalSplit = ((bool)(resources.GetObject("dgrdVendor.AllowHorizontalSplit")));
			this.dgrdVendor.AllowRowSelect = ((bool)(resources.GetObject("dgrdVendor.AllowRowSelect")));
			this.dgrdVendor.AllowSort = ((bool)(resources.GetObject("dgrdVendor.AllowSort")));
			this.dgrdVendor.AllowUpdate = ((bool)(resources.GetObject("dgrdVendor.AllowUpdate")));
			this.dgrdVendor.AllowUpdateOnBlur = ((bool)(resources.GetObject("dgrdVendor.AllowUpdateOnBlur")));
			this.dgrdVendor.AllowVerticalSplit = ((bool)(resources.GetObject("dgrdVendor.AllowVerticalSplit")));
			this.dgrdVendor.AlternatingRows = ((bool)(resources.GetObject("dgrdVendor.AlternatingRows")));
			this.dgrdVendor.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dgrdVendor.Anchor")));
			this.dgrdVendor.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.BackgroundImage")));
			this.dgrdVendor.BorderStyle = ((System.Windows.Forms.BorderStyle)(resources.GetObject("dgrdVendor.BorderStyle")));
			this.dgrdVendor.Caption = resources.GetString("dgrdVendor.Caption");
			this.dgrdVendor.CaptionHeight = ((int)(resources.GetObject("dgrdVendor.CaptionHeight")));
			this.dgrdVendor.CellTipsDelay = ((int)(resources.GetObject("dgrdVendor.CellTipsDelay")));
			this.dgrdVendor.CellTipsWidth = ((int)(resources.GetObject("dgrdVendor.CellTipsWidth")));
			this.dgrdVendor.ChildGrid = ((C1.Win.C1TrueDBGrid.C1TrueDBGrid)(resources.GetObject("dgrdVendor.ChildGrid")));
			this.dgrdVendor.CollapseColor = ((System.Drawing.Color)(resources.GetObject("dgrdVendor.CollapseColor")));
			this.dgrdVendor.ColumnFooters = ((bool)(resources.GetObject("dgrdVendor.ColumnFooters")));
			this.dgrdVendor.ColumnHeaders = ((bool)(resources.GetObject("dgrdVendor.ColumnHeaders")));
			this.dgrdVendor.DefColWidth = ((int)(resources.GetObject("dgrdVendor.DefColWidth")));
			this.dgrdVendor.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dgrdVendor.Dock")));
			this.dgrdVendor.EditDropDown = ((bool)(resources.GetObject("dgrdVendor.EditDropDown")));
			this.dgrdVendor.EmptyRows = ((bool)(resources.GetObject("dgrdVendor.EmptyRows")));
			this.dgrdVendor.Enabled = ((bool)(resources.GetObject("dgrdVendor.Enabled")));
			this.dgrdVendor.ExpandColor = ((System.Drawing.Color)(resources.GetObject("dgrdVendor.ExpandColor")));
			this.dgrdVendor.ExposeCellMode = ((C1.Win.C1TrueDBGrid.ExposeCellModeEnum)(resources.GetObject("dgrdVendor.ExposeCellMode")));
			this.dgrdVendor.ExtendRightColumn = ((bool)(resources.GetObject("dgrdVendor.ExtendRightColumn")));
			this.dgrdVendor.FetchRowStyles = ((bool)(resources.GetObject("dgrdVendor.FetchRowStyles")));
			this.dgrdVendor.FilterBar = ((bool)(resources.GetObject("dgrdVendor.FilterBar")));
			this.dgrdVendor.FlatStyle = ((C1.Win.C1TrueDBGrid.FlatModeEnum)(resources.GetObject("dgrdVendor.FlatStyle")));
			this.dgrdVendor.Font = ((System.Drawing.Font)(resources.GetObject("dgrdVendor.Font")));
			this.dgrdVendor.GroupByAreaVisible = ((bool)(resources.GetObject("dgrdVendor.GroupByAreaVisible")));
			this.dgrdVendor.GroupByCaption = resources.GetString("dgrdVendor.GroupByCaption");
			this.dgrdVendor.Images.Add(((System.Drawing.Image)(resources.GetObject("resource1"))));
			this.dgrdVendor.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dgrdVendor.ImeMode")));
			this.dgrdVendor.LinesPerRow = ((int)(resources.GetObject("dgrdVendor.LinesPerRow")));
			this.dgrdVendor.Location = ((System.Drawing.Point)(resources.GetObject("dgrdVendor.Location")));
			this.dgrdVendor.MarqueeStyle = C1.Win.C1TrueDBGrid.MarqueeEnum.DottedCellBorder;
			this.dgrdVendor.Name = "dgrdVendor";
			this.dgrdVendor.PictureAddnewRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureAddnewRow")));
			this.dgrdVendor.PictureCurrentRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureCurrentRow")));
			this.dgrdVendor.PictureFilterBar = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureFilterBar")));
			this.dgrdVendor.PictureFooterRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureFooterRow")));
			this.dgrdVendor.PictureHeaderRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureHeaderRow")));
			this.dgrdVendor.PictureModifiedRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureModifiedRow")));
			this.dgrdVendor.PictureStandardRow = ((System.Drawing.Image)(resources.GetObject("dgrdVendor.PictureStandardRow")));
			this.dgrdVendor.PreviewInfo.AllowSizing = ((bool)(resources.GetObject("dgrdVendor.PreviewInfo.AllowSizing")));
			this.dgrdVendor.PreviewInfo.Caption = resources.GetString("dgrdVendor.PreviewInfo.Caption");
			this.dgrdVendor.PreviewInfo.Location = ((System.Drawing.Point)(resources.GetObject("dgrdVendor.PreviewInfo.Location")));
			this.dgrdVendor.PreviewInfo.Size = ((System.Drawing.Size)(resources.GetObject("dgrdVendor.PreviewInfo.Size")));
			this.dgrdVendor.PreviewInfo.ToolBars = ((bool)(resources.GetObject("dgrdVendor.PreviewInfo.ToolBars")));
			this.dgrdVendor.PreviewInfo.UIStrings.Content = ((string[])(resources.GetObject("dgrdVendor.PreviewInfo.UIStrings.Content")));
			this.dgrdVendor.PreviewInfo.ZoomFactor = ((System.Double)(resources.GetObject("dgrdVendor.PreviewInfo.ZoomFactor")));
			this.dgrdVendor.PrintInfo.MaxRowHeight = ((int)(resources.GetObject("dgrdVendor.PrintInfo.MaxRowHeight")));
			this.dgrdVendor.PrintInfo.OwnerDrawPageFooter = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.OwnerDrawPageFooter")));
			this.dgrdVendor.PrintInfo.OwnerDrawPageHeader = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.OwnerDrawPageHeader")));
			this.dgrdVendor.PrintInfo.PageFooter = resources.GetString("dgrdVendor.PrintInfo.PageFooter");
			this.dgrdVendor.PrintInfo.PageFooterHeight = ((int)(resources.GetObject("dgrdVendor.PrintInfo.PageFooterHeight")));
			this.dgrdVendor.PrintInfo.PageHeader = resources.GetString("dgrdVendor.PrintInfo.PageHeader");
			this.dgrdVendor.PrintInfo.PageHeaderHeight = ((int)(resources.GetObject("dgrdVendor.PrintInfo.PageHeaderHeight")));
			this.dgrdVendor.PrintInfo.PrintHorizontalSplits = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.PrintHorizontalSplits")));
			this.dgrdVendor.PrintInfo.ProgressCaption = resources.GetString("dgrdVendor.PrintInfo.ProgressCaption");
			this.dgrdVendor.PrintInfo.RepeatColumnFooters = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.RepeatColumnFooters")));
			this.dgrdVendor.PrintInfo.RepeatColumnHeaders = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.RepeatColumnHeaders")));
			this.dgrdVendor.PrintInfo.RepeatGridHeader = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.RepeatGridHeader")));
			this.dgrdVendor.PrintInfo.RepeatSplitHeaders = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.RepeatSplitHeaders")));
			this.dgrdVendor.PrintInfo.ShowOptionsDialog = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.ShowOptionsDialog")));
			this.dgrdVendor.PrintInfo.ShowProgressForm = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.ShowProgressForm")));
			this.dgrdVendor.PrintInfo.ShowSelection = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.ShowSelection")));
			this.dgrdVendor.PrintInfo.UseGridColors = ((bool)(resources.GetObject("dgrdVendor.PrintInfo.UseGridColors")));
			this.dgrdVendor.RecordSelectors = ((bool)(resources.GetObject("dgrdVendor.RecordSelectors")));
			this.dgrdVendor.RecordSelectorWidth = ((int)(resources.GetObject("dgrdVendor.RecordSelectorWidth")));
			this.dgrdVendor.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dgrdVendor.RightToLeft")));
			this.dgrdVendor.RowDivider.Color = ((System.Drawing.Color)(resources.GetObject("resource.Color1")));
			this.dgrdVendor.RowDivider.Style = ((C1.Win.C1TrueDBGrid.LineStyleEnum)(resources.GetObject("resource.Style1")));
			this.dgrdVendor.RowHeight = ((int)(resources.GetObject("dgrdVendor.RowHeight")));
			this.dgrdVendor.RowSubDividerColor = ((System.Drawing.Color)(resources.GetObject("dgrdVendor.RowSubDividerColor")));
			this.dgrdVendor.ScrollTips = ((bool)(resources.GetObject("dgrdVendor.ScrollTips")));
			this.dgrdVendor.ScrollTrack = ((bool)(resources.GetObject("dgrdVendor.ScrollTrack")));
			this.dgrdVendor.Size = ((System.Drawing.Size)(resources.GetObject("dgrdVendor.Size")));
			this.dgrdVendor.SpringMode = ((bool)(resources.GetObject("dgrdVendor.SpringMode")));
			this.dgrdVendor.TabAcrossSplits = ((bool)(resources.GetObject("dgrdVendor.TabAcrossSplits")));
			this.dgrdVendor.TabIndex = ((int)(resources.GetObject("dgrdVendor.TabIndex")));
			this.dgrdVendor.Text = resources.GetString("dgrdVendor.Text");
			this.dgrdVendor.ViewCaptionWidth = ((int)(resources.GetObject("dgrdVendor.ViewCaptionWidth")));
			this.dgrdVendor.ViewColumnWidth = ((int)(resources.GetObject("dgrdVendor.ViewColumnWidth")));
			this.dgrdVendor.Visible = ((bool)(resources.GetObject("dgrdVendor.Visible")));
			this.dgrdVendor.WrapCellPointer = ((bool)(resources.GetObject("dgrdVendor.WrapCellPointer")));
			this.dgrdVendor.RowColChange += new C1.Win.C1TrueDBGrid.RowColChangeEventHandler(this.dgrdVendor_RowColChange);
			this.dgrdVendor.BeforeRowColChange += new C1.Win.C1TrueDBGrid.CancelEventHandler(this.dgrdVendor_BeforeRowColChange);
			this.dgrdVendor.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dgrdVendor_KeyDown);
			this.dgrdVendor.PropBag = resources.GetString("dgrdVendor.PropBag");
			// 
			// label1
			// 
			this.label1.AccessibleDescription = resources.GetString("label1.AccessibleDescription");
			this.label1.AccessibleName = resources.GetString("label1.AccessibleName");
			this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor")));
			this.label1.AutoSize = ((bool)(resources.GetObject("label1.AutoSize")));
			this.label1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label1.Dock")));
			this.label1.Enabled = ((bool)(resources.GetObject("label1.Enabled")));
			this.label1.Font = ((System.Drawing.Font)(resources.GetObject("label1.Font")));
			this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
			this.label1.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.ImageAlign")));
			this.label1.ImageIndex = ((int)(resources.GetObject("label1.ImageIndex")));
			this.label1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label1.ImeMode")));
			this.label1.Location = ((System.Drawing.Point)(resources.GetObject("label1.Location")));
			this.label1.Name = "label1";
			this.label1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label1.RightToLeft")));
			this.label1.Size = ((System.Drawing.Size)(resources.GetObject("label1.Size")));
			this.label1.TabIndex = ((int)(resources.GetObject("label1.TabIndex")));
			this.label1.Text = resources.GetString("label1.Text");
			this.label1.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.TextAlign")));
			this.label1.Visible = ((bool)(resources.GetObject("label1.Visible")));
			// 
			// btnHelp
			// 
			this.btnHelp.AccessibleDescription = resources.GetString("btnHelp.AccessibleDescription");
			this.btnHelp.AccessibleName = resources.GetString("btnHelp.AccessibleName");
			this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnHelp.Anchor")));
			this.btnHelp.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnHelp.BackgroundImage")));
			this.btnHelp.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnHelp.Dock")));
			this.btnHelp.Enabled = ((bool)(resources.GetObject("btnHelp.Enabled")));
			this.btnHelp.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnHelp.FlatStyle")));
			this.btnHelp.Font = ((System.Drawing.Font)(resources.GetObject("btnHelp.Font")));
			this.btnHelp.Image = ((System.Drawing.Image)(resources.GetObject("btnHelp.Image")));
			this.btnHelp.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.ImageAlign")));
			this.btnHelp.ImageIndex = ((int)(resources.GetObject("btnHelp.ImageIndex")));
			this.btnHelp.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnHelp.ImeMode")));
			this.btnHelp.Location = ((System.Drawing.Point)(resources.GetObject("btnHelp.Location")));
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnHelp.RightToLeft")));
			this.btnHelp.Size = ((System.Drawing.Size)(resources.GetObject("btnHelp.Size")));
			this.btnHelp.TabIndex = ((int)(resources.GetObject("btnHelp.TabIndex")));
			this.btnHelp.Text = resources.GetString("btnHelp.Text");
			this.btnHelp.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnHelp.TextAlign")));
			this.btnHelp.Visible = ((bool)(resources.GetObject("btnHelp.Visible")));
			// 
			// lblType
			// 
			this.lblType.AccessibleDescription = resources.GetString("lblType.AccessibleDescription");
			this.lblType.AccessibleName = resources.GetString("lblType.AccessibleName");
			this.lblType.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblType.Anchor")));
			this.lblType.AutoSize = ((bool)(resources.GetObject("lblType.AutoSize")));
			this.lblType.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblType.Dock")));
			this.lblType.Enabled = ((bool)(resources.GetObject("lblType.Enabled")));
			this.lblType.Font = ((System.Drawing.Font)(resources.GetObject("lblType.Font")));
			this.lblType.Image = ((System.Drawing.Image)(resources.GetObject("lblType.Image")));
			this.lblType.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblType.ImageAlign")));
			this.lblType.ImageIndex = ((int)(resources.GetObject("lblType.ImageIndex")));
			this.lblType.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblType.ImeMode")));
			this.lblType.Location = ((System.Drawing.Point)(resources.GetObject("lblType.Location")));
			this.lblType.Name = "lblType";
			this.lblType.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblType.RightToLeft")));
			this.lblType.Size = ((System.Drawing.Size)(resources.GetObject("lblType.Size")));
			this.lblType.TabIndex = ((int)(resources.GetObject("lblType.TabIndex")));
			this.lblType.Text = resources.GetString("lblType.Text");
			this.lblType.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblType.TextAlign")));
			this.lblType.Visible = ((bool)(resources.GetObject("lblType.Visible")));
			// 
			// cboType
			// 
			this.cboType.AccessibleDescription = resources.GetString("cboType.AccessibleDescription");
			this.cboType.AccessibleName = resources.GetString("cboType.AccessibleName");
			this.cboType.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("cboType.Anchor")));
			this.cboType.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cboType.BackgroundImage")));
			this.cboType.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("cboType.Dock")));
			this.cboType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboType.Enabled = ((bool)(resources.GetObject("cboType.Enabled")));
			this.cboType.Font = ((System.Drawing.Font)(resources.GetObject("cboType.Font")));
			this.cboType.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("cboType.ImeMode")));
			this.cboType.IntegralHeight = ((bool)(resources.GetObject("cboType.IntegralHeight")));
			this.cboType.ItemHeight = ((int)(resources.GetObject("cboType.ItemHeight")));
			this.cboType.Location = ((System.Drawing.Point)(resources.GetObject("cboType.Location")));
			this.cboType.MaxDropDownItems = ((int)(resources.GetObject("cboType.MaxDropDownItems")));
			this.cboType.MaxLength = ((int)(resources.GetObject("cboType.MaxLength")));
			this.cboType.Name = "cboType";
			this.cboType.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("cboType.RightToLeft")));
			this.cboType.Size = ((System.Drawing.Size)(resources.GetObject("cboType.Size")));
			this.cboType.TabIndex = ((int)(resources.GetObject("cboType.TabIndex")));
			this.cboType.Text = resources.GetString("cboType.Text");
			this.cboType.Visible = ((bool)(resources.GetObject("cboType.Visible")));
			this.cboType.SelectedIndexChanged += new System.EventHandler(this.cboType_SelectedIndexChanged);
			// 
			// lblDaily
			// 
			this.lblDaily.AccessibleDescription = resources.GetString("lblDaily.AccessibleDescription");
			this.lblDaily.AccessibleName = resources.GetString("lblDaily.AccessibleName");
			this.lblDaily.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblDaily.Anchor")));
			this.lblDaily.AutoSize = ((bool)(resources.GetObject("lblDaily.AutoSize")));
			this.lblDaily.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblDaily.Dock")));
			this.lblDaily.Enabled = ((bool)(resources.GetObject("lblDaily.Enabled")));
			this.lblDaily.Font = ((System.Drawing.Font)(resources.GetObject("lblDaily.Font")));
			this.lblDaily.Image = ((System.Drawing.Image)(resources.GetObject("lblDaily.Image")));
			this.lblDaily.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblDaily.ImageAlign")));
			this.lblDaily.ImageIndex = ((int)(resources.GetObject("lblDaily.ImageIndex")));
			this.lblDaily.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblDaily.ImeMode")));
			this.lblDaily.Location = ((System.Drawing.Point)(resources.GetObject("lblDaily.Location")));
			this.lblDaily.Name = "lblDaily";
			this.lblDaily.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblDaily.RightToLeft")));
			this.lblDaily.Size = ((System.Drawing.Size)(resources.GetObject("lblDaily.Size")));
			this.lblDaily.TabIndex = ((int)(resources.GetObject("lblDaily.TabIndex")));
			this.lblDaily.Text = resources.GetString("lblDaily.Text");
			this.lblDaily.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblDaily.TextAlign")));
			this.lblDaily.Visible = ((bool)(resources.GetObject("lblDaily.Visible")));
			// 
			// lblWeekly
			// 
			this.lblWeekly.AccessibleDescription = resources.GetString("lblWeekly.AccessibleDescription");
			this.lblWeekly.AccessibleName = resources.GetString("lblWeekly.AccessibleName");
			this.lblWeekly.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblWeekly.Anchor")));
			this.lblWeekly.AutoSize = ((bool)(resources.GetObject("lblWeekly.AutoSize")));
			this.lblWeekly.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblWeekly.Dock")));
			this.lblWeekly.Enabled = ((bool)(resources.GetObject("lblWeekly.Enabled")));
			this.lblWeekly.Font = ((System.Drawing.Font)(resources.GetObject("lblWeekly.Font")));
			this.lblWeekly.Image = ((System.Drawing.Image)(resources.GetObject("lblWeekly.Image")));
			this.lblWeekly.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblWeekly.ImageAlign")));
			this.lblWeekly.ImageIndex = ((int)(resources.GetObject("lblWeekly.ImageIndex")));
			this.lblWeekly.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblWeekly.ImeMode")));
			this.lblWeekly.Location = ((System.Drawing.Point)(resources.GetObject("lblWeekly.Location")));
			this.lblWeekly.Name = "lblWeekly";
			this.lblWeekly.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblWeekly.RightToLeft")));
			this.lblWeekly.Size = ((System.Drawing.Size)(resources.GetObject("lblWeekly.Size")));
			this.lblWeekly.TabIndex = ((int)(resources.GetObject("lblWeekly.TabIndex")));
			this.lblWeekly.Text = resources.GetString("lblWeekly.Text");
			this.lblWeekly.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblWeekly.TextAlign")));
			this.lblWeekly.Visible = ((bool)(resources.GetObject("lblWeekly.Visible")));
			// 
			// lblMonthly
			// 
			this.lblMonthly.AccessibleDescription = resources.GetString("lblMonthly.AccessibleDescription");
			this.lblMonthly.AccessibleName = resources.GetString("lblMonthly.AccessibleName");
			this.lblMonthly.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblMonthly.Anchor")));
			this.lblMonthly.AutoSize = ((bool)(resources.GetObject("lblMonthly.AutoSize")));
			this.lblMonthly.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblMonthly.Dock")));
			this.lblMonthly.Enabled = ((bool)(resources.GetObject("lblMonthly.Enabled")));
			this.lblMonthly.Font = ((System.Drawing.Font)(resources.GetObject("lblMonthly.Font")));
			this.lblMonthly.Image = ((System.Drawing.Image)(resources.GetObject("lblMonthly.Image")));
			this.lblMonthly.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblMonthly.ImageAlign")));
			this.lblMonthly.ImageIndex = ((int)(resources.GetObject("lblMonthly.ImageIndex")));
			this.lblMonthly.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblMonthly.ImeMode")));
			this.lblMonthly.Location = ((System.Drawing.Point)(resources.GetObject("lblMonthly.Location")));
			this.lblMonthly.Name = "lblMonthly";
			this.lblMonthly.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblMonthly.RightToLeft")));
			this.lblMonthly.Size = ((System.Drawing.Size)(resources.GetObject("lblMonthly.Size")));
			this.lblMonthly.TabIndex = ((int)(resources.GetObject("lblMonthly.TabIndex")));
			this.lblMonthly.Text = resources.GetString("lblMonthly.Text");
			this.lblMonthly.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblMonthly.TextAlign")));
			this.lblMonthly.Visible = ((bool)(resources.GetObject("lblMonthly.Visible")));
			// 
			// PODeliveryByHour
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.CancelButton = this.btnClose;
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.lblMonthly);
			this.Controls.Add(this.lblWeekly);
			this.Controls.Add(this.lblDaily);
			this.Controls.Add(this.cboType);
			this.Controls.Add(this.lblType);
			this.Controls.Add(this.btnSave);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.pnlRoleProtection);
			this.Controls.Add(this.btnHelp);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.KeyPreview = true;
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "PODeliveryByHour";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Load += new System.EventHandler(this.PODeliveryByHour_Load);
			this.pnlRoleProtection.ResumeLayout(false);
			this.pnlRight.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgrdData)).EndInit();
			this.pnlLeft.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgrdVendor)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion


		private void btnClose_Click(object sender, EventArgs e)
		{
			this.Close();
		}
		/// <summary>
		/// ConfigGrid
		/// </summary>
		/// <author>Trada</author>
		/// <date>Tuesday, Feb 7 2006</date>
		private void ConfigGrid(bool pblnLock)
		{
			for (int i =0; i <dgrdData.Splits[0].DisplayColumns.Count; i++)
			{
				dgrdData.Splits[0].DisplayColumns[i].Locked = true;
			}
			dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.COMMENT_FLD].Locked = false;
			dgrdData.Enabled = true;
			switch (cboType.SelectedIndex)
			{
				case 0: //Daily
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = pblnLock;
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = pblnLock;
					break;
				case 1: //Weekly
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = pblnLock;
					break;
				case 2:	//Monthly
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = false;
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = pblnLock;
					break;
			}
			dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.CCNID_FLD].Visible = false;
			dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD].Locked = pblnLock;
			dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.UNITPRICE_FLD].Locked = pblnLock;
			dgrdData.Splits[0].DisplayColumns[TIME].Locked = pblnLock;
			dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD].Locked = pblnLock;
				
			if (!pblnLock)
			{
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD].Button = true;
				dgrdData.Splits[0].DisplayColumns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD].Button = true;
			}
		}
		/// <summary>
		/// Fill Data to grid by PartyID
		/// </summary>
		/// <param name="pintPartyID"></param>
		/// <author>Trada</author>
		/// <date>Tuesday, Feb 7 2006</date>
		private void FillDataToGrid(int pintPartyID, int pintType)
		{
			if(dstData.Tables.Count == 0) return;
			string strWeekOrMonth = string.Empty;
			if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Weekly)
			{
				strWeekOrMonth = PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD + " ASC,";
			}
			else if (cboType.SelectedIndex == (int)PODeliveryTypeEnum.Monthly)
			{
				strWeekOrMonth = PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD + " ASC,";
			}

			DataRow[] adrowData = dstData.Tables[0].Select(PO_VendorDeliveryScheduleTable.PARTYID_FLD + " = " + pintPartyID.ToString() 
				+ " AND " + PO_VendorDeliveryScheduleTable.DELIVERYTYPE_FLD + " = " + pintType.ToString(),
				ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD + " ASC," + strWeekOrMonth + " Time ASC");
			//Convert to DataTable
			dtbData = dstData.Tables[0].Clone();
			for (int i = 0; i < adrowData.Length; i++)
			{
				DataRow drowNew = dtbData.NewRow();
				foreach (DataColumn dcol in dtbData.Columns)
				{
					drowNew[dcol.Caption] = adrowData[i][dcol.Caption];
				}
				dtbData.Rows.Add(drowNew);
			}
			dtbData.AcceptChanges();
			dgrdData.DataSource = dtbData;
			C1DateEdit dtmTime = new C1DateEdit();
			dtmTime.FormatType = FormatTypeEnum.CustomFormat;
			dtmTime.CustomFormat = TIME_FORMAT;
			dtmTime.ShowUpDownButtons = false;
			dtmTime.ShowDropDownButton = false;
			
			dgrdData.Columns[TIME].Editor = dtmTime;
			dgrdData.Columns[TIME].NumberFormat = TIME_FORMAT;
			// cboDayOfMonth.
			ComboBox cboDayOfMonth = new ComboBox();
			FormControlComponents.InitDayOfMonthComboBox(cboDayOfMonth);
			dgrdData.Columns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Editor = cboDayOfMonth;
			// cboWeek.
			string[] arrItems = DayOfWeekEnum.GetNames(typeof(DayOfWeekEnum));
			dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].ValueItems.Presentation = PresentationEnum.ComboBox;
			dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].ValueItems.Translate = true;
			dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].ValueItems.MaxComboItems = 7;
			dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].ValueItems.Validate = true;
			for(int i = 0;i < arrItems.Length; i++)
			{
				//dtbWeek.Rows.Add(new object[] {i+1,arrItems[i]});
				ValueItem vi = new ValueItem((i).ToString(),arrItems[i]); //(arrValue.GetValue(i).ToString(),arrItems[i]);	
				dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].ValueItems.Values.Add(vi);
			}

			FormControlComponents.RestoreGridLayout(dgrdData, dtbGridLayOut);
			if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Weekly)
			{
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = true;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = true;
			}
			else if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Monthly)
			{
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = true;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = true;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = false;
			}
			else
			{
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = true;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = true;
			}

			ConfigGrid(false);
		}
		
		/// <summary>
		/// PODeliveryByHour_Load
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Tuesday, Feb 7 2006</date>
		private void PODeliveryByHour_Load(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".PODeliveryByHour_Load()";
			try
			{
				//Set authorization for user
				Security objSecurity = new Security();
				this.Name = THIS;
				if(objSecurity.SetRightForUserOnForm(this, SystemProperty.UserName) == 0)
				{
					this.Close();
					// You don't have the right to view this item
					PCSMessageBox.Show(ErrorCode.MESSAGE_YOU_HAVE_NO_RIGHT_TO_VIEW ,MessageBoxIcon.Warning);
					return;
				}
				//Fill data to grid
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = 
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
				dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = 
					dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = true;
				//Store grid layout
				dtbGridLayOut = FormControlComponents.StoreGridLayout(dgrdData);
                //Get Vendor 
				PODeliveryByHourBO boPODeliveryByHour = new PODeliveryByHourBO();
				dstVendor = boPODeliveryByHour.GetVendor();
				DataTable dtbStoreVendorLayout = FormControlComponents.StoreGridLayout(dgrdVendor);
				dgrdVendor.DataSource = dstVendor.Tables[0];
				FormControlComponents.RestoreGridLayout(dgrdVendor, dtbStoreVendorLayout);
				dgrdVendor.Splits[0].DisplayColumns[MST_PartyTable.PARTYID_FLD].Visible = false;
				dgrdVendor.Splits[0].DisplayColumns[MST_PartyTable.PARTYID_FLD].Locked = true;
				for(int i=4; i < dgrdVendor.Splits[0].DisplayColumns.Count;i++)
				{
					dgrdVendor.Splits[0].DisplayColumns[i].Visible = false;	
					dgrdVendor.Splits[0].DisplayColumns[i].Locked = true;
				}

				dgrdVendor.Row = 0;
				dgrdVendor.Focus();
				//Load Type
				cboType.Items.Clear();
				cboType.Items.Add(lblDaily.Text);	// = 0
				cboType.Items.Add(lblWeekly.Text);   // = 1
				cboType.Items.Add(lblMonthly.Text);   // = 2
				cboType.SelectedIndex = 0;
				//Get all VendorDeliverySchedule
				dstData = boPODeliveryByHour.GetVendorDeliverySchedule();
				if(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString() != string.Empty)
				{
					FillDataToGrid(int.Parse(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString()), cboType.SelectedIndex);
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// fill data to grid 
		/// </summary>
		/// <param name="pdrowData"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void FillItemData(DataRow pdrowData)
		{
			dgrdData.EditActive = true;
			dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD].Value = pdrowData[ITM_ProductTable.CODE_FLD].ToString();
			dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD].Value = pdrowData[ITM_ProductTable.DESCRIPTION_FLD].ToString();
			dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.REVISION_FLD].Value = pdrowData[ITM_ProductTable.REVISION_FLD].ToString();
			dgrdData.Columns[ITM_ProductTable.PRODUCTID_FLD].Value = pdrowData[ITM_ProductTable.PRODUCTID_FLD].ToString();

		}
		/// <summary>	
		/// dgrdData_ButtonClick
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void dgrdData_ButtonClick(object sender, ColEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_ButtonClick()";
			try
			{
				//Part Number
				if (dgrdData.Col == dgrdData.Columns.IndexOf(dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD])) 
				{
					//open the search form to select Product
					//Hashtable htbCondition = new Hashtable();
					DataRowView drwResult = null;
					//htbCondition.Add(ITM_ProductTable.PRIMARYVENDORID_FLD, int.Parse(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString()));
					if (dgrdData.AddNewMode == AddNewModeEnum.AddNewCurrent)
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.CODE_FLD, dgrdData[dgrdData.Row, ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD].ToString(), null, true);
					else
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.CODE_FLD, dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD].Text.Trim(), null, true);
					if (drwResult != null)
						FillItemData(drwResult.Row);
				}
				//Part Name
				if (dgrdData.Col == dgrdData.Columns.IndexOf(dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD])) 
				{
					//open the search form to select Product
					//Hashtable htbCondition = new Hashtable();
					DataRowView drwResult = null;
					//htbCondition.Add(ITM_ProductTable.PRIMARYVENDORID_FLD, int.Parse(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString()));
					if (dgrdData.AddNewMode == AddNewModeEnum.AddNewCurrent)
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.DESCRIPTION_FLD, dgrdData[dgrdData.Row, ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD].ToString(), null, true);
					else
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.DESCRIPTION_FLD, dgrdData.Columns[ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD].Text.Trim(), null, true);
					if (drwResult != null)
						FillItemData(drwResult.Row);
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// dgrdData_BeforeColUpdate
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void dgrdData_BeforeColUpdate(object sender, BeforeColUpdateEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_BeforeColUpdate()";
			try
			{
				if (e.Column.DataColumn.Value.ToString() == string.Empty) return;
				//Hashtable htbCriteria = new Hashtable();
				DataRowView drwResult = null;
				//htbCriteria.Add(ITM_ProductTable.PRIMARYVENDORID_FLD, int.Parse(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString()));
				//Part Number 
				if (e.Column.DataColumn.DataField == ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD)
				{
					if (dgrdData.Columns[e.Column.DataColumn.DataField].Text.Trim() != string.Empty)
					{
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.CODE_FLD, dgrdData.Columns[e.Column.DataColumn.DataField].Text.Trim(), null, false);
						if (drwResult != null)
							e.Column.DataColumn.Tag = drwResult.Row;
						else
							e.Cancel = true;
					}
				}
				//Part Name
				if (e.Column.DataColumn.DataField == ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD)
				{
					if (dgrdData.Columns[e.Column.DataColumn.DataField].Text.Trim() != string.Empty)
					{
						drwResult = FormControlComponents.OpenSearchForm(ITM_ProductTable.TABLE_NAME, ITM_ProductTable.DESCRIPTION_FLD, dgrdData.Columns[e.Column.DataColumn.DataField].Text.Trim(), null, false);
						if (drwResult != null)
							e.Column.DataColumn.Tag = drwResult.Row;
						else
							e.Cancel = true;
					}
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// dgrdData_AfterColUpdate
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void dgrdData_AfterColUpdate(object sender, ColEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_AfterColUpdate()";
			try
			{
				if (e.Column.DataColumn.DataField == ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD 
					|| e.Column.DataColumn.DataField == ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD)
				{
					if ((e.Column.DataColumn.Tag == null) ||( e.Column.DataColumn.Value.ToString() == string.Empty))
					{
						int row = dgrdData.Row;
						dgrdData[row, ITM_ProductTable.TABLE_NAME + ITM_ProductTable.CODE_FLD] = string.Empty;
						dgrdData[row, ITM_ProductTable.TABLE_NAME + ITM_ProductTable.DESCRIPTION_FLD] = string.Empty;
						dgrdData[row, ITM_ProductTable.TABLE_NAME + ITM_ProductTable.REVISION_FLD] = string.Empty;
					}
					else
						FillItemData((DataRow) e.Column.DataColumn.Tag);
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		
		}
		/// <summary>
		/// cboType_SelectedIndexChanged
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void cboType_SelectedIndexChanged(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".cboType_SelectedIndexChanged()";
			try
			{
				dgrdVendor_RowColChange(sender,null);

				switch (cboType.SelectedIndex)
				{
					case 0: //Daily
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = 
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = 
							dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = true;
						break;
					case 1: //Weekly
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = false;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = true;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = false;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = true;
						
						break;
					case 2:	//Monthly
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Visible = false;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD].Locked = true;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Locked = false;
						dgrdData.Splits[0].DisplayColumns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].Visible = true;
						
						break;
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}
		/// <summary>
		/// btnSave_Click
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Thursday, Feb 9 2006</date>
		private void btnSave_Click(object sender, EventArgs e)
		{
			const string METHOD_NAME = THIS + ".btnSave_Click()";
			try
			{
				dgrdVendor_BeforeRowColChange(sender,null);
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		private void dgrdVendor_RowColChange(object sender, RowColChangeEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdVendor_AfterRowColChange()";
			try
			{
				try // if load form dgrdVendor has no data
				{
					if(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString() != string.Empty)
					{
						PODeliveryByHourBO boPODelivery = new PODeliveryByHourBO();
						dstData = boPODelivery.GetVendorDeliverySchedule();
						FillDataToGrid(int.Parse(dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD].ToString()), cboType.SelectedIndex);
					}
				}
				catch{}

			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		private void dgrdData_BeforeDelete(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdData_BeforeDelete()";
			try
			{
				if(dgrdData[dgrdData.Row,PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD] != DBNull.Value)
				{
					DataRow[] drows = dstData.Tables[0].Select(PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD + 
						" = " + dgrdData[dgrdData.Row,PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD]);
					foreach(DataRow drow in drows)
					{
						drow.Delete();
					}
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		/// <summary>
		/// Save data into database
		/// </summary>
		/// <returns></returns>
		bool SaveData()
		{
			// Check mandatory
			for(int i = 0; i < dgrdData.RowCount; i++)
			{
				if(dgrdData[i,TIME] == DBNull.Value)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxButtons.OK,MessageBoxIcon.Error);
					dgrdData.Row = i;
					dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[TIME]);
					return false;
				}
				if(dgrdData[i,ITM_ProductTable.TABLE_NAME+ITM_ProductTable.CODE_FLD] == DBNull.Value)
				{
					PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxButtons.OK,MessageBoxIcon.Error);
					dgrdData.Row = i;
					dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[ITM_ProductTable.TABLE_NAME+ITM_ProductTable.CODE_FLD]);
					return false;
				}
				if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Weekly)
				{
					if(dgrdData[i,PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxButtons.OK,MessageBoxIcon.Error);
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD]);
						return false;
					}
				}
				else if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Monthly)
				{
					if(dgrdData[i,PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD] == DBNull.Value)
					{
						PCSMessageBox.Show(ErrorCode.MANDATORY_INVALID,MessageBoxButtons.OK,MessageBoxIcon.Error);
						dgrdData.Row = i;
						dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD]);
						return false;
					}
				}
					
			}
			// Check duplicate data
			for(int i = 0; i < dgrdData.RowCount; i++)
			{
				int intProductID = 0;
				if(dgrdData[i,ITM_ProductTable.PRODUCTID_FLD].ToString() != string.Empty)
					intProductID = Convert.ToInt32(dgrdData[i,ITM_ProductTable.PRODUCTID_FLD]);
				DataRow[] drowDups = dstData.Tables[0].Select(ITM_ProductTable.PRODUCTID_FLD + "=" + intProductID
					+ " AND " + PO_VendorDeliveryScheduleTable.DELIVERYTYPE_FLD + "<>" + cboType.SelectedIndex);
				if(drowDups.Length > 0)
				{
					//PCSMessageBox.Show(ErrorCode.DUPLICATE_KEY,MessageBoxButtons.OK,MessageBoxIcon.Error);
					PCSMessageBox.Show(ErrorCode.MESSAGE_ITEM_BELONG_ANOTHER_TYPE,MessageBoxButtons.OK,MessageBoxIcon.Error);
					dgrdData.Row = i; 
					dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[ITM_ProductTable.TABLE_NAME+ITM_ProductTable.CODE_FLD]);
					return false;
				}
				// check date in month [1..31]
				if(cboType.SelectedIndex == (int)PODeliveryTypeEnum.Monthly)
				{
					int intDate = 0;
					if(dgrdData[i,PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD].ToString() != string.Empty)
					{
						intDate = Convert.ToInt32(dgrdData[i,PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD]);
						if((intDate < MIN_DATE) || (intDate > MAX_DATE))
						{
							PCSMessageBox.Show(ErrorCode.MESSAGE_NUMBER_MUST_IN_SCOPE,MessageBoxIcon.Error, new string[]{MIN_DATE.ToString(),MAX_DATE.ToString()});
							dgrdData.Row = i; 
							dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD]);
							return false;
						}
					}
				}
				for(int j = i + 1; j < dgrdData.RowCount; j++)
				{
					if(dgrdData[j,ITM_ProductTable.PRODUCTID_FLD].ToString() != string.Empty)
					if(Convert.ToInt32(dgrdData[i,ITM_ProductTable.PRODUCTID_FLD]) == Convert.ToInt32(dgrdData[j,ITM_ProductTable.PRODUCTID_FLD]))
					{
						// Dialy
						if (cboType.SelectedIndex == (int)PODeliveryTypeEnum.Daily)
						{
							int iHour = ((DateTime)dgrdData[i,TIME]).Hour;
							int jHour = ((DateTime)dgrdData[j,TIME]).Hour;
							int iMin = ((DateTime)dgrdData[i,TIME]).Minute;
							int jMin = ((DateTime)dgrdData[j,TIME]).Minute;
							if((iHour == jHour) && (iMin == jMin))
							{
								PCSMessageBox.Show(ErrorCode.DUPLICATE_KEY,MessageBoxButtons.OK,MessageBoxIcon.Error);
								dgrdData.Row = j; 
								dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[TIME]);
								return false;
							}
						}
						else if (cboType.SelectedIndex == (int)PODeliveryTypeEnum.Weekly) // Weekly
						{
							int iHour = ((DateTime)dgrdData[i,TIME]).Hour;
							int jHour = ((DateTime)dgrdData[j,TIME]).Hour;
							int iMin = ((DateTime)dgrdData[i,TIME]).Minute;
							int jMin = ((DateTime)dgrdData[j,TIME]).Minute;
							int iWeek = Convert.ToInt32(dgrdData[i,PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD]);
							int jWeek = Convert.ToInt32(dgrdData[j,PO_VendorDeliveryScheduleTable.WEEKLYDAY_FLD]);
							if((iHour == jHour) && (iMin == jMin) && (iWeek==jWeek))
							{
								PCSMessageBox.Show(ErrorCode.DUPLICATE_KEY,MessageBoxButtons.OK,MessageBoxIcon.Error);
								dgrdData.Row = j; 
								dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[TIME]);
								return false;
							}
						}
						else if (cboType.SelectedIndex == (int)PODeliveryTypeEnum.Monthly) // Monthly
						{
							int iHour = ((DateTime)dgrdData[i,TIME]).Hour;
							int jHour = ((DateTime)dgrdData[j,TIME]).Hour;
							int iMin = ((DateTime)dgrdData[i,TIME]).Minute;
							int jMin = ((DateTime)dgrdData[j,TIME]).Minute;
							int iMonth = Convert.ToInt32(dgrdData[i,PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD]);
							int jMonth = Convert.ToInt32(dgrdData[j,PO_VendorDeliveryScheduleTable.MONTHLYDATE_FLD]);
							if((iHour == jHour) && (iMin == jMin) && (iMonth==jMonth))
							{
								PCSMessageBox.Show(ErrorCode.DUPLICATE_KEY,MessageBoxButtons.OK,MessageBoxIcon.Error);
								dgrdData.Row = j; 
								dgrdData.Col = dgrdData.Columns.IndexOf(dgrdData.Columns[TIME]);
								return false;
							}
						}

					}
				}
                    
			}


			// Update to dstData
			foreach(DataRow drow1 in dstData.Tables[0].Rows)
			{
				if(drow1.RowState == DataRowState.Deleted) continue;
				foreach(DataRow drow2 in dtbData.Rows)
				{
					//if(drow2.RowState == DataRowState.Deleted) continue;
					if(drow2.RowState == DataRowState.Modified)
						if(Convert.ToInt32(drow2[PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD])
							==Convert.ToInt32(drow1[PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD]))
						{
							drow1.ItemArray = drow2.ItemArray;
							drow1[PO_VendorDeliveryScheduleTable.DELHOUR_FLD] = ((DateTime)drow1[TIME]).Hour;
							drow1[PO_VendorDeliveryScheduleTable.DELMIN_FLD] = ((DateTime)drow1[TIME]).Minute;
							//drow2.Delete();
						}
				}
			}
			// Insert new row
			foreach(DataRow drow2 in dtbData.Rows)
			{
				if(drow2.RowState == DataRowState.Added)
				{
					drow2[PO_VendorDeliveryScheduleTable.DELHOUR_FLD] = ((DateTime)drow2[TIME]).Hour;
					drow2[PO_VendorDeliveryScheduleTable.DELMIN_FLD] = ((DateTime)drow2[TIME]).Minute;
					dstData.Tables[0].Rows.Add(drow2.ItemArray);
					//drow2.Delete();
				}
			}

			// Delete row
			DataRow[] drowDels = dtbData.Select(string.Empty,string.Empty,DataViewRowState.Deleted);
			foreach(DataRow drow2 in drowDels)
			{
				drow2.RejectChanges();
				int intID = 0;
				if(drow2[PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD] != DBNull.Value)
				{
					intID = Convert.ToInt32(drow2[PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD]);
					DataRow[] drows = dstData.Tables[0].Select(PO_VendorDeliveryScheduleTable.VENDORDELIVERYSCHEDULE_FLD + "=" + intID);
					if(drows.Length > 0 ) drows[0].Delete();
				}
			}

			PODeliveryByHourBO boPODelivery = new PODeliveryByHourBO();
			boPODelivery.UpdateDataSet(dstData);
			dstData = boPODelivery.GetVendorDeliverySchedule();
			FillDataToGrid(Convert.ToInt32(dgrdVendor[dgrdVendor.Row,PO_VendorDeliveryScheduleTable.PARTYID_FLD]),cboType.SelectedIndex);
			PCSMessageBox.Show(ErrorCode.MESSAGE_AFTER_SAVE_DATA);
			return true;
		}

		private void dgrdData_Error(object sender, ErrorEventArgs e)
		{
			e.Handled = true;
			e.Continue = true;
		}

		private void dgrdVendor_BeforeRowColChange(object sender, CancelEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdVendor_BeforeRowColChange()";
			try
			{
				if(dtbData.GetChanges() != null)
				{
					foreach(DataRow drow in dtbData.Rows)
					{
						if(drow.RowState == DataRowState.Added ) 
							if(drow[TIME] != DBNull.Value)
							{
								drow[PO_VendorDeliveryScheduleTable.DELHOUR_FLD] = ((DateTime)drow[TIME]).Hour;
								drow[PO_VendorDeliveryScheduleTable.DELMIN_FLD] = ((DateTime)drow[TIME]).Minute;
								drow[PO_VendorDeliveryScheduleTable.DELIVERYTYPE_FLD] = cboType.SelectedIndex;
								drow[PO_VendorDeliveryScheduleTable.CCNID_FLD] = SystemProperty.CCNID;
								drow[PO_VendorDeliveryScheduleTable.PARTYID_FLD] = dgrdVendor[dgrdVendor.Row, MST_PartyTable.PARTYID_FLD];
							}
					}
				}

				if(dtbData.GetChanges() != null)
					if (dtbData.GetChanges().Rows.Count > 0)
					{
						DialogResult confirmDialog = PCSMessageBox.Show(ErrorCode.MESSAGE_QUESTION_STORE_INTO_DATABASE, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
						if (confirmDialog == DialogResult.Yes)
						{
							//btnSave_Click(sender, e);
							if(!SaveData())
							{
								if(e != null)
								{
									e.Cancel = true;
									return;
								}
							}
						}
						else if(confirmDialog == DialogResult.Cancel)
						{
							if(e != null)
								e.Cancel = true;
							return;
						}
					}

			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}

		private void dgrdData_KeyDown(object sender, KeyEventArgs e)
		{
			switch (e.KeyCode) 
			{
				case Keys.F1:
					break;
				case Keys.F2:
					// ClearAllFilter();
					break;
				case Keys.F3:
					// FilterWithCurrentValue(false);
					break;
				case Keys.F4:
					// Open search form
					dgrdData_ButtonClick(null,null);
					break;
				case Keys.F5:
					// ReturnPreviousFilter();
					break;
				case Keys.F6:
					// RowFilter();
					break;
				case Keys.F7:
					break;
				case Keys.F8:
					// SumCurrentColumn();
					break;
				case Keys.F9:
					// ExportDataToExcel();
					break;
				case Keys.F10:
					// PrintDataToPrinter();
					break;
				case Keys.F11:
					// SelectDataFromTable();
					break;
				case Keys.Delete:
					FormControlComponents.DeleteMultiRowsOnTrueDBGrid(dgrdData);
					break;
			}		
		}
		/// <summary>
		/// dgrdVendor_KeyDown
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// <author>Trada</author>
		/// <date>Wednesday, April 12 2006</date>
		private void dgrdVendor_KeyDown(object sender, KeyEventArgs e)
		{
			const string METHOD_NAME = THIS + ".dgrdVendor_KeyDown()";
			try
			{
				if ((e.KeyCode == Keys.Up)||(e.KeyCode == Keys.Down))
				{
					dgrdVendor_RowColChange(sender, null);
				}
			}
			catch (PCSException ex)
			{
				// Displays the error message if throwed from PCSException.
				PCSMessageBox.Show(ex.mCode, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex.CauseException, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
			catch (Exception ex)
			{
				// Displays the error message if throwed from system.
				PCSMessageBox.Show(ErrorCode.OTHER_ERROR, MessageBoxIcon.Error);
				try
				{
					// Log error message into log file.
					Logger.LogMessage(ex, METHOD_NAME, Level.ERROR);
				}
				catch
				{
					// Show message if logger has an error.
					PCSMessageBox.Show(ErrorCode.LOG_EXCEPTION, MessageBoxIcon.Error);
				}
			}
		}


	}
}
